package com.example.roomdatabasetest;

import static androidx.room.OnConflictStrategy.REPLACE;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;
import java.util.List;

// 对于实体类的进行操作
@Dao
public interface CarDao {
    //替换冲突
    @Insert(onConflict = REPLACE)
    void insertCar(Car... car);
    //查询汽车
    @Query("Select * from Cars")
    List<Car> queryAllCars();
    //查询匹配品牌的汽车
    @Query("select * from cars where car_brand == :brand")
    List<Car> queryThatBrandCars(String brand);
    //查询价格在某个区间上的，between的用法相当于在<=和>=之间
    @Query("select * from cars where car_price between :min and :max ")
    List<Car> queryCarsBetweenPrice(int min,int max);
    //删除某个Car
    @Delete()
    void deleteCar(Car car);
    //更新某个Car
    @Update(onConflict = REPLACE)
    void updateCars(Car... cars);
}
